<template>
  <div class="cart">
    <div class="cart-s">
      <span class="dl">登录后享受更多优惠</span>
      <a class="qdl" @click="goto">去登录</a>
      <van-icon name="arrow" size="20" />
    </div>
    <div class="cart-zho">
      <span class="zho-zi">购物车还是空的</span>
      <div class="zho-an"><a href="/home">去逛逛</a></div>
    </div>
    <!-- 加入商品列表 -->
    <van-card
      title="小米8 屏幕指纹版"
      thumb="https://img01.yzcdn.cn/vant/ipad.jpeg"
    >
      <template #price> ￥7999 </template>
      <template #bottom>
        <van-stepper v-model="value" input-width="38px" button-size="35px" />
      </template>
      <template #num>
        <van-icon name="delete-o" size="24" />
      </template>
    </van-card>
    <!-- 一张图 -->
    <img
      src="../../../public/cart.jpg"
      alt="猜你喜欢"
      width="100%"
      height="100%"
    />
    <!-- 商品列表 -->
    <div class="cart-x">
      <div class="cart-item" v-for="item in list" :key="item.id">
        <div class="cart-list">
          <img :src="item.img" alt="" />
        </div>
        <div class="title">{{ item.name }}</div>
        <div class="cart-ziti">
          {{ item.content }}
        </div>
        <div class="price">￥{{ item.price }}</div>
      </div>
    </div>
  </div>
</template>
<script>
import { getList } from '../../api/cart'
export default {
  data: () => ({
    list: [],
    value: 1
  }),
  methods: {
    async getList() {
      const res = await getList()
      this.list = res.data.message
    },
    goto() {
      this.$router.push('/login')
    }
  },
  created() {
    this.getList()
  }
}
</script>
<style lang="less">
.cart {
  .cart-s {
    height: 65px;
    background: white;
    display: flex;
    align-items: center;
    .dl {
      margin-left: 15px;
    }
    .qdl {
      color: #969799;
      font-size: 14px;
      margin-left: 140px;
      margin-right: 5px;
    }
    .van-icon-arrow {
      color: #969799;
    }
  }
  .cart-zho {
    height: 70px;
    background: #ebebeb;
    display: flex;
    align-items: center;
    .zho-zi {
      display: inline-block;
      width: 105px;
      height: 40px;
      line-height: 40px;
      margin-left: 86px;
      font-size: 15px;
      color: rgba(0, 0, 0, 0.27);
    }
    .zho-an {
      width: 71px;
      height: 25px;
      margin-left: 10px;
      font-size: 15px;
      border: 1px solid rgba(0, 0, 0, 0.15);
      text-align: center;
      line-height: 25px;
      a {
        color: #000;
      }
      :active {
        color: #000;
      }
    }
  }
  .van-card {
    height: 131px;
    background-color: white;
    margin-top: 0px;
    padding: 15px 20px;
    .van-card__thumb {
      width: 100px;
      height: 100px;
      display: inline-block;
    }
    .van-card__title {
      font-size: 14px;
      color: #646566;
    }
    .van-card__price {
      color: #999;
      margin-top: 6px;
    }
    .van-stepper {
      margin-bottom: 30px;
      margin-top: 10px;
    }
    .van-card__num {
      width: 24px;
      height: 24px;
      margin-top: 42px;
    }
  }
  .cart-x {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 46px;
    .cart-item {
      width: 49%;
      padding-bottom: 10px;
      .cart-list {
        margin-top: -4px;
        img {
          width: 100%;
        }
      }
      .title {
        font-size: 18px;
        text-indent: 10px;
      }
      .cart-ziti {
        font-size: 0.25rem;
        color: rgba(0, 0, 0, 0.54);
        text-indent: 10px;
      }
      .price {
        color: #ea625b;
        text-indent: 10px;
        margin-top: 5px;
      }
    }
  }
}
</style>
